from django.db import models

# Create your models here.
class UrlCount(models.Model):
    host=models.GenericIPAddressField()
    domain=models.CharField(max_length=200)
    url=models.CharField(max_length=500)
    count=models.IntegerField()
    access_time=models.CharField(max_length=100)
    create_at=models.DateTimeField(blank=True,auto_now_add=True)

    def __unicode__(self):
        return "{0}  {1}  {2} ".format(self.count,self.url,self.domain)
class Domain(models.Model):
    host=models.GenericIPAddressField()
    port=models.CharField(max_length=200)
    domain=models.CharField(max_length=200)

    def __unicode__(self):
        return "{0} {1} {2}".format(self.host,self.port,self.domain)


class Methon(models.Model):
    methon=models.CharField(max_length=100)

    def __unicode__(self):
        return "{0}".format(self.methon)


class Url(models.Model):
    url=models.URLField()
    code=models.IntegerField(default=200)
    size=models.IntegerField(null=True,blank=True)
    methon=models.ForeignKey("Methon")
    time=models.IntegerField(default=3600)
    create_at=models.DateTimeField(blank=True,auto_now_add=True)

    def __unicode__(self):
        return "{0}".format(self.url)